package com.easy.service.impl;

import com.easy.bean.Bill;
import com.easy.mapper.BillDao;
import com.easy.service.BillService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BillServiceImpl implements BillService {
    @Autowired
    BillDao billDao;
    //新增数据
    @Override
    public Bill add(Bill bill) {
        billDao.add(bill);
    //通过主键查询数据库中的数据
        Bill result=billDao.one(bill.getId());
        return result;
    }

    @Override
    public int del(Integer id) {
        return billDao.del(id);
    }

    @Override
    public Bill edit(Bill bill) {
        billDao.edit(bill);
        Bill result=billDao.one(bill.getId());
        return result;
    }

    @Override
    public List<Bill> all(Bill bill) {

        return billDao.all(bill);
    }

    @Override
    public Bill one(Integer id) {
        return billDao.one(id);
    }
@Override
    public void page(Page page, Bill bill) {
        int count = billDao.pageCount(bill);
        Object data=billDao.page(page, bill);
        page.setCount(count);
        page.setData(data);
    }
}
